function output = diff_encode(input)
    output = zeros(length(input),1);
    output(1) = input(1);
    diff_i = real(input(1));
    diff_q = imag(input(1));
    for i=2:length(input)
        if(xor(real(input(i)),imag(input(i))==0))
            diff_i = xor(diff_i,real(input(i)));
            diff_q = xor(diff_q,imag(input(i)));
            output(i) = diff_i + 1i*diff_q;
        else
            diff_i = xor(real(input(i)),diff_q);
            diff_q = xor(imag(input(i)),diff_i);
            output(i) = diff_i + 1i*diff_q;
        end
    end
end

